<template>
  <div class="consensus-activity-asset">
    <c-title :text="text"></c-title>
    <div class="head" v-if="type == 1 && origin_asset_list.length!==0">
      <template v-for="(item,i) in origin_asset_list">
        <span>{{item.origin_asset.name}}：{{item.amount}}</span>
        <span class="line" v-if="i+1!==origin_asset_list.length"></span>
      </template>
    </div>
    <div class="nav">
      <div class="reopen"  v-if="type == 2">
        <p>当前{{ custom_name.reopen_name }}</p>
        <p class="bold fz48">{{ reopen }}</p>
      </div>
      <div class="nav-box">
        <router-link :to="fun.getUrl('consensus_activity_asset_withdraw', { num: 1, name: (type == 1 ? 'asset' : 'reopen') })"
          class="flex w33">
          <span class="bg bg-F15353">
            <i class="iconfont icon-ht_content_tixian"></i>
          </span>
          <span class="fz24 mt22">转入加权分红额度</span>
        </router-link>
        <router-link :to="fun.getUrl('consensus_activity_asset_withdraw', { num: 2, name: (type == 1 ? 'asset' : 'reopen') })"
          class="flex w33">
          <span class="bg bg-FF8846">
            <i class="iconfont icon-huiyuanguanli-copy"></i>
          </span>
          <span class="fz24 mt22">转入{{ custom_name.quality_name }}</span>
        </router-link>
        <router-link v-if="type == 2"
          :to="fun.getUrl('consensus_activity_asset_withdraw', { num: 6, name: (type == 1 ? 'asset' : 'reopen') })" class="flex w33">
          <span class="bg bg-4898FF">
            <i class="iconfont icon-card_collect_b"></i>
          </span>
          <span class="fz24 mt22">转入{{ point_name }}</span>
        </router-link>
        <router-link :to="fun.getUrl('consensus_activity_asset_withdraw', { num: 3, name: (type == 1 ? 'asset' : 'reopen') })"
          class="flex w33">
          <span class="bg bg-4898FF">
            <i class="iconfont icon-card_collect_b"></i>
          </span>
          <span class="fz24 mt22">转入{{ integral_name || custom_name.integral_name}}</span>
        </router-link>
        <router-link v-if="type == 1"
          :to="fun.getUrl('consensus_activity_asset_withdraw', { num: 5, name: (type == 1 ? 'asset' : 'reopen') })" class="flex w33">
          <span class="bg bg-4898FF">
            <i class="iconfont icon-pd_leveltag"></i>
          </span>
          <span class="fz24 mt22">会员转让</span>
        </router-link>
        <router-link :to="fun.getUrl('consensus_activity_asset_withdraw', { num: 4, name: (type == 1 ? 'asset' : 'reopen') })"
          class="flex w33 ">
          <span class="bg bg-FF8846">
            <i class="iconfont icon-balance_a_n1"></i>
          </span>
          <span class="fz24 mt22">转入{{ custom_name.yuan_withdraw_limit_name }}</span>
        </router-link>
      </div>
    </div>
    <p class="tips">明细记录</p>
    <div class="list" v-if="list&&list.length!==0">
      <div class="box" v-for="(item, i) in list" :key="i">
        <div class="between">
          <span class="bold fz28">{{item.source_name}}</span>
          <span>{{ item.change_value }}</span>
        </div>
        <div class="box-bottom between" >
          <div class="hidden">
            <span>{{ item.mark}}</span>
          </div>
          <span style="flex-shrink: 0;">{{item.created_at}}</span>
        </div>
        <!-- <div class="box-bottom between" v-else>
          <span >{{item.mark}}</span>
          <span>{{item.created_at}}</span>
        </div> -->
        <div class="line" v-if="i+1 !== list.length"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { scrollMixin } from "../../utils/mixin";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      text: "",
      type: null,
      reopen: 0,
      integral_name: "",
      point_name: "",
      custom_name: {},
      origin_asset_list :[],

      list: [],
      total_page: 1,
      isLoadMore: true,
      page: 1,
    };
  },
  activated() {
    this.type = Number(this.$route.params.num);
    this.getData();
    this.getRecord()
  },
  methods: {
    getMoreData() {
      this.isLoadMore = false;
      if (this.page >= this.total_page) {
        return;
      }
      let page = this.page + 1;
      this.getRecord(page);
    },
    getRecord(page = 1) {
      let url = "plugin.wise-yuan-trade.frontend.reopen-value.record";
      if(this.type==1){
        url  = 'plugin.wise-yuan-trade.frontend.origin-asset.record';
      }
      $http.get(url, { page }, "").then(res => {
        this.isLoadMore = true;
        if (res.result) {
          let data = res.data;
          (page==1)?(this.list=data.data):(this.list=this.list.concat(data.data));
          this.total_page = data.last_page;
          this.page = data.current_page;
        } else {
          this.$toast(res.msg);
        }
      })
    },
    getData() {
      let url ="plugin.wise-yuan-trade.frontend.reopen-value.index";
      if(this.type==1){
        url  = 'plugin.wise-yuan-trade.frontend.origin-asset.index';
      }
      $http.get(url, "", "").then(res => {
        if (res.result) {
          let data = res.data;
          this.custom_name = data.custom_name;
          if (this.type == 1) {
            this.text = data.custom_name.origin_asset_name;
            this.origin_asset_list = data.origin_asset_list ;
          } else if (this.type == 2) {
            this.integral_name = data.integral_name;
            this.point_name = data.point_name;
            this.text = data.custom_name.reopen_name;
            this.reopen = data.reopen;
          }
        } else {
          this.$toast(res.msg);
        }
      })
    },
  }
};
</script>

<style scoped lang="scss">
.consensus-activity-asset {
  padding: 0.625rem 0.75rem;

  .hidden {
    overflow-x: scroll;
    white-space: nowrap;
    margin-right: 0.625rem;
  }

  .hidden::-webkit-scrollbar {
    display: none;
  }

  .w33 {
    width: 33.33%;
  }

  .fz24 {
    font-size: 0.75rem;
  }

  .flex {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 0.625rem;
    padding: 0.3438rem 0 1.25rem;
    margin-top: 0.625rem;
  }

  .reopen {
    width: 100%;
    font-size: 0.8125rem;
    margin-bottom: 1.4688rem;
    margin-top: 1.4375rem;
  }

  .nav-box {
    display: flex;
    flex-wrap: wrap;

    a {
      margin-top: 0.9063rem;
    }
  }

  .bg-F15353 {
    background: #f15353;
  }

  .bg-FF8846 {
    background: #ff8846;
  }

  .bg-4898FF {
    background: #4898ff;
  }

  .bg {
    padding: 0.7188rem 0.6563rem;
    border-radius: 0.625rem;
    width: 2.5rem;
    height: 2.5rem;
    color: #fff;
  }

  .mt22 {
    margin-top: 0.6875rem;
  }

  .mt39 {
    margin-top: 1.2188rem;
  }

  .head {
    background: #fff;
    border-radius: 0.625rem;
    padding: 1.2188rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: baseline;

    .line {
      margin: 1.2188rem 0;
      width: 100%;
      height: 1px;
      background: #f0f0f1;
    }
  }

  .fz28 {
    font-size: 0.875rem;
  }

  .fz48 {
    font-size: 1.5rem;
  }

  .bold {
    font-weight: bold;
  }

  .line {
    width: 100%;
    height: 1px;
    background: #ccc;
    margin: 1.0625rem 0 0.9375rem;
  }

  .box-bottom {
    margin-top: 0.5rem;
    color: #aaaab3;
    font-size: 0.75rem;
  }

  .list {
    background: #fff;
    padding: 0.9375rem 0.75rem;
    border-radius: 0.625rem;
  }

  .between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .tips {
    margin: 0.875rem 0.75rem;
    font-weight: bold;
    font-size: 0.9375rem;
    text-align: left;
  }
}
</style>
